#!/bin/bash
#########################################################################
# Author      : zkk@crscd.com.cn
# Created Time: 2015/2/16 10:01:59
# File Name   : get_info.sh
# Description : $1 precise
#########################################################################
in="ori."$1".txt"
name=$1
#grep "^Size:" $in | sed "s/Size:\s\+//" > raw.size.$in
#grep "^Filename:" $in | sed "s/Filename:\s\+/http:\/\/mirrors.163.com\/ubuntu\//" > raw.fname.$in
grep "^Filename:" $in | sed "s/Filename:\s\+/http:\/\/mirrors.163.com\/ubuntu\//" > $name.txt

#fname="data.py"
fname=$1".py"

echo "#!/usr/env python " > $fname
echo '# This file is auto-generated by get_info.sh' >> $fname
echo '# https://git.oschina.net/kzhuo/pytools/simple-apt-tool ' >> $fname
echo '# ' >> $fname

echo "fsize=[" >> $fname
#for s in `cat raw.size.$in`
#do
#	echo $s"," >> $fname
#done
#sed "s/$/,/" raw.size.$in >> $fname
grep "^Size:" $in | sed "s/Size:\s\+//" | sed "s/$/,/" >> $fname
echo ']' >> $fname
echo '' >> $fname

echo "fname=[" >> $fname
#for s in `cat raw.fname.$in`
#do
#	echo '"'$s'",' >> $fname
#done
sed "s/^/'/" $name.txt | sed "s/$/',/" >> $fname
echo ']' >> $fname
